<template>
  <div class="maxCom">
    <div class="singleComMin" @click="clickCommonCom(showData.comId)" ref="singleRefMin" @mouseenter="maxSpecialMin()" @mouseleave="minSpecialMin()" >
      <div class="managerDiv">
        <div class="maxComFour">
          <el-button type="danger" class="statusEle" size="medium" plain disabled>{{showData.serStatus}}</el-button>
        </div>
        <div>
          <img :src="showData.img" class="commonProShowImg"/>
        </div>
        <div>
          <span>
            {{showData.comSerName}} &nbsp;{{showData.colorName}}
          </span><br/>
          <span>
            ￥{{showData.price}}
          </span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import {waxSpecial} from "commonjs/const/waxSpecial";
  import {preShas} from "commonjs/const/preShake";


  export default {
    name: "commonTier",
    props: {
      data: {
        type: Object
      }
    },
    data(){
      return {
        showData: this.data,
        preSha: false
      }
    },
    methods: {
      clickCommonCom(comId){//普通商品点击事件
        this.$router.push({path: "/detail",query: { comId }})
      },
      maxSpecialMin(){
        let element = this.$refs.singleRefMin;
        //调用防抖函数
        //preShas(waxSpecial,element,1.1,1,true,0)()
        waxSpecial(element, 1.1, 1, true).then(data => {
          this.preSha = data;
        })

      },
      minSpecialMin(){
        let tempInter = setInterval(() => {
          if (this.preSha) {
            this.preSha = false;
            let element = this.$refs.singleRefMin;
            //调用防抖函数
            waxSpecial(element,1,1,true);
            clearInterval(tempInter)
          }
        },1)
      }
    }
  }
</script>

<style scoped>
  .maxComFour{
    margin-top: 20px;
    margin-right: 140px;
  }
  .singleComMin{
    width: 280px;
    height: 400px;
    background-color: white;
  }

  .maxCom{
    cursor: pointer;
  }
  .managerDiv{
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }
  .commonProShowImg{
    width: 220px;
    height: 100%;
  }
  .managerDiv div{
    margin-bottom: 8%;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 18px;
  }
</style>
